// 根据栏目id获取新闻列表数据
import axios from "../utils/index";

// 文章列表
export const getPostAPI = (params) => {
  return axios({
    method: "get",
    url: "/post",

    params,
  });
};
// 文章详情
export const getPostDetailByIdAPI = (id) => {
  return axios({
    method: "GET",
    url: `/post/${id}`,
  });
};
// 文章点赞和取消点赞是同一个接口
export const updatePostLikeByIdAPI = (id) => {
  return axios({
    method: "GET",
    url: `/post_like/${id}`,
  });
};
// 收藏文章
export const updatePostStarByIdAPI = (id) => {
  return axios({
    method: "GET",
    url: `/post_star/${id}`,
  });
};

// 评论列表
export const getPostCommentByIdAPI = (id, params) => {
  return axios({
    method: "get",
    url: `/post_comment/${id}`,
    params,
  });
};
//发表评论
export const publishPostCommentAPI = (id, data) => {
  return axios({
    method: "post",
    url: `/post_comment/${id}`,
    data,
  });
};

// 搜索文章
export const getPostSearchAPI = (params) => {
  return axios({
    method: "get",
    url: `/post_search`,
    params,
  });
};

// 发布文章

export const getpublishAPI = (data) => {
  return axios({
    method: "post",
    url: `/post`,
    data,
  });
};

// 编辑文章
export const getEditpublishAPI = (id, data) => {
  return axios({
    method: "post",
    url: `/post_update/${id}`,
    data,
  });
};
